package letter_grade;

public class LetterToNumeric {

	private String letter;
	private String modificator;
	
	public LetterToNumeric(String note){
		letter = note.substring(0, 1);
		modificator = note.substring(1);
	}
	
	public double getNumericGrade(){
		double grade;
		switch(letter){
			case "A": grade = 4; break;
			case "B": grade = 3; break;
			case "C": grade = 2; break;
			case "D": grade = 1; break;
			case "F": grade = 0; break;
			default: return -1;
		}
		switch(modificator){
		case "+":
			if(letter.equals("F"))
				return -1;
			else if(!(letter.equals("A")))
				grade += 0.3;
			break;
		case "-":
			if(!(letter.equals("F")))
				grade -= 0.3;
			else
				return -1;
			break;
		case "": break;
		default: return -1;
		}
	return grade;
	}
}
